/*
 * @Author: 杨光辉(GerhardYang)
 * @Date: 2020-12-14 13:09:26
 * @LastEditors: 杨光辉(GerhardYang)
 * @LastEditTime: 2021-06-05 13:36:06
 * @Description: file content
 * @Copyright: 超图软件华中平台客户中心 (SuperMap Software Co., Ltd. -Central China Platform)
 */

const path = require("path");
//引入该插件
const CompressionPlugin = require("compression-webpack-plugin");

module.exports = {
  publicPath: "./",
  productionSourceMap: false,
  // 开发阶段跨域代理
  devServer: {
    proxy: {
      "/iportal": {
        target: "http://localhost:8190/",
        changeOrigin: true,
      },
      // '/vehicl': {
      //     target: "http://59.231.8.131:82/",
      //     changeOrigin: true,
      //     pathRewrite: {
      //         '^/vehicl': '/'
      //     }
      // }
    },
  },
  // 全局less变量
  pluginOptions: {
    "style-resources-loader": {
      preProcessor: "less",
      patterns: [path.resolve(__dirname, "src/assets/style/main.less")],
    },
  },
  css: {
    loaderOptions: {
      less: {
        javascriptEnabled: true,
      },
    },
  },
  configureWebpack: {
    plugins: [
      new CompressionPlugin({
        test: /\.(js|css)(\?.*)?$/i, //需要压缩的文件正则
        threshold: 10240, //文件大小大于这个值时启用压缩
        deleteOriginalAssets: false, //压缩后保留原文件
      }),
    ],
  },
};
